<template>
  <component
    :is="itemComponent"
    :item="item"
    v-bind="{ ...item }"
  />
</template>

<script lang="ts" setup>
import { camelCase, upperFirst } from "lodash-es";
import * as formItemComponentMap from "@/views/formgen/components/FormItem/index";
import { BasicComponent } from "@/views/formgen/components/GenerateForm/types/form";

const props = defineProps<{
  item: BasicComponent;
}>();

let name = upperFirst(camelCase(props.item?.config?.tag));

// @ts-ignore
const itemComponent = formItemComponentMap[name];
</script>

<style lang="scss" scoped></style>
